# 大类：经营状况
# 小类：微信公众号

import json
import time


# 22-微信公众号信息-2018-05-26
def get_weixin(mongo_instance, soup, cid, company):
    print('start 微信公众号数据*******')
    if soup.find('div', attrs={'tyc-event-ch': 'CompangyDetail.wechat'}):

        scripts = soup.find('div', attrs={'tyc-event-ch': 'CompangyDetail.wechat'}).find_all('script')
        for script in scripts:
            item = json.loads(script.text)
            item['company_id'] = cid
            item['company'] = company
            item['create_at'] = int(time.time())
            item['update_at'] = item['create_at']
            print(item)
            # title:公众号的标题
            # titleImgURL ：微信号图片
            # codeImg ：微信号二维码图片
            # publicNum：微信号
            # recommend：微信号的描述
            mongo_instance.weixin.update({'company_id': cid}, item, True)
    print('success 微信公众号数据*******')
